﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title> 
    <script src="../lib/jquery/jquery-1.11.3.min.js"></script>
    <script src="../lib/jquery.form.js"></script>
</head>
<body>
    <form id="form1" method="post">
        <input type="file" name="file" id="file1" />
        <input type="file" name="file" id="file2" />
        <button type="submit" id="demo1">ShXxSperm提交</button>
    </form>
    <form id="form2" method="post">
        <input type="file" name="file" id="file2"/>
        <button type="submit" id="demo2">ShXxFile提交</button>
    </form>
    <form id="form3" method="post"> 
        <button type="submit" id="demo3">ShXxDa提交</button>
    </form>
    <form id="form4" method="post"> 
        <button type="submit" id="demo4">ShXxsync提交</button>
    </form>
    <script>
        var json1 = [{
            'vbatch':'LOT20240221001',
            'tcheckoutDate': '2024-02-21', 'vcheckoutTime': '10:12',
            'voperator': '张三', 'wtype': '鲜精', 'ddensity': 213.48, 'dvitality': 94.55, 'icopies': 12,
            'dadd': 632, 'vresult': '757',
            'dcapacity': 60, 'dmilliliter': 125, 'dmotileSperms': 2000,
            'dmalformation': 2115.06, 'bstandard': true, 'vfile': [{ 'vtpmc': 'DD1234-C1-1', 'vfile':'category-a.png'}],
            'mxlist': [{ 'vgzgP': 'DD1234', 'tcsrq': '2021-01-02', 'vpz': 'DD', 'vpx': '美系' }]
        }
        ];
        var json2 = [];
        var json3 = [{
            'tcsrq': '2018-12-03',
            'vdadm': 'testvdadm',  
            'vdadm': "testvdadm",
            'vpz': "testvpz",
            'bsfzc': true,
            
        }
        ];
        var json4 = [{
            'tcsrq': '2018-12-03',
            'vdadm': 'testvdadm',
            'vdadm': "testvdadm",
            'vpz': "testvpz",
            'bsfzc': true,
        }
        ];
        $("#demo1").on('click', function () {
            sub(1, "http://api.humuyun.com/api/ShXxSperm");
            return false;
        });
        $("#demo2").on('click', function () {
            sub(2, "http://api.humuyun.com/api/ShXxFile");
            return false;
        });
        $("#demo3").on('click', function () {
            sub(3, "http://api.humuyun.com/api/ShXxDa");
            return false;
        });
        $("#demo4").on('click', function () {
            sub(4, "http://api.humuyun.com/api/ShXxsync");
            return false;
        });


        function sub(type, url) {
            var jsondata = json1;
            if (type == "1") {
                var file = $("#file1")[0].files[0]
                console.log(file.name)
                jsondata = json1;
                $("#form1").ajaxSubmit({
                    url: url, 
                    data: {
                        appkey: "7492D92B81024810D757D87A4702BF01",
                        deviceId: "MYJCN1D009Y17",
                        data: JSON.stringify(jsondata)
                    },
                    type: "POST",
                    dataType: "html",
                    success: function (ret) {
                        alert(ret)
                    }
                })
            }
            if (type == "2") {
                $("#form2").ajaxSubmit({
                    url: url,
                    data: {
                        appkey: "7492D92B81024810D757D87A4702BF01",
                        deviceId: "MYJCN1D009Y17" 
                    },
                    type: "POST",
                    dataType: "html",
                    success: function (ret) {
                        alert(ret)
                    }
                })
            }
            if (type == "3") {
                jsondata = json3;
                $("#form3").ajaxSubmit({
                    url: url,
                    data: {
                        appkey: "7492D92B81024810D757D87A4702BF01",
                        deviceId: "MYJCN1D009Y17",
                        data: JSON.stringify(jsondata)
                    },
                    type: "POST",
                    dataType: "html",
                    success: function (ret) {
                        alert(ret)
                    }
                })
            }
            if (type == "4") {
                jsondata = json4;
                console.log(jsondata)
                $("#form4").ajaxSubmit({
                    url: url,
                    data: {
                        appkey: "7492D92B81024810D757D87A4702BF01",
                        deviceId: "MYJCN1D009Y17",
                        data: JSON.stringify(jsondata)
                    },
                    type: "POST",
                    dataType: "html",
                    success: function (ret) {
                        alert(ret)
                    }
                })
            }

            return false;
        }
    </script>
</body>
</html>